package 尚硅谷.juc.test15;

import java.util.concurrent.locks.ReentrantLock;

/**
 *
 */
public class ProdConsumer {
    public static void main(String[] args) {
        ShareData shareData=new ShareData();
        /**
         * 调用自增
         */
        new Thread(()->{
            for (int i=1;i<=10;i++){
                try {
                    shareData.increment();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"AA").start();
        /**
         * 调用自减
         */
        new Thread(()->{
            for (int i=1;i<=10;i++){
                try {
                    shareData.decrement();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"BB").start();

        /**
         * 调用自增
         */
        new Thread(()->{
            for (int i=1;i<=10;i++){
                try {
                    shareData.increment();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"CC").start();
        /**
         * 调用自减
         */
        new Thread(()->{
            for (int i=1;i<=10;i++){
                try {
                    shareData.decrement();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"DD").start();
    }
}
